﻿using Microsoft.AspNetCore.Mvc;
using SmartAnswerPlatform.IService.System;
using SmartAnswerPlatform.Models.Entitys.System;
using SmartAnswerPlatform.Models.RequestModels;
using SmartAnswerPlatform.Models.ViewModels.System;

namespace SmartAnswerPlatform.WebApi.Controllers.System
{
    [Route("userRole")]
    public class SysUserRoleController : BaseController
    {
        private readonly ISysUserRoleService _sysUserRoleService;

        public SysUserRoleController(ISysUserRoleService sysUserRoleService)
        {
            _sysUserRoleService = sysUserRoleService;
        }

        [HttpPost("findAll")]
        public async Task<ActionResult> FindAll()
        {
            return Success(await _sysUserRoleService.FindAll());
        }

        [HttpPost("add")]
        public async Task<ActionResult> Add([FromBody] SysUserRoleViewModel userRoleViewModel)
        {
            return Success(await _sysUserRoleService.Insert(userRoleViewModel));
        }

        [HttpPost("update")]
        public async Task<ActionResult> update([FromBody] SysUserRoleViewModel userRoleViewModel)
        {
            return Success(await _sysUserRoleService.Update(userRoleViewModel));
        }

        [HttpPost("delete")]
        public async Task<ActionResult> delete([FromBody] IdRequestModels idRequest)
        {
            return Success(await _sysUserRoleService.Delete(idRequest.Id));
        }
    }
}
